package com.logictech.lims.web.back;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jeecgframework.p3.core.util.SystemTools;
import org.jeecgframework.p3.core.util.plugin.ViewVelocity;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.logictech.lims.entity.Log;
import com.logictech.lims.service.LogService;

/**
 * 描述：</b>LogController<br>
 * 日志
 * 
 * @author guoqi
 * @since：2017年04月20日 03时25分36秒 星期四
 * @version:1.0
 */
@Controller
@RequestMapping("/lims/back/log")
public class LogController extends BaseController {
	@Autowired
	private LogService logService;

	/**
	 * 列表页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "list", method = { RequestMethod.GET, RequestMethod.POST })
	public void list(@ModelAttribute Log query, HttpServletResponse response, HttpServletRequest request,
			@RequestParam(required = false, value = "pageNo", defaultValue = "1") int pageNo,
			@RequestParam(required = false, value = "pageSize", defaultValue = "10") int pageSize) throws Exception {
		PageQuery<Log> pageQuery = new PageQuery<Log>();
		pageQuery.setPageNo(pageNo);
		pageQuery.setPageSize(pageSize);
		VelocityContext velocityContext = new VelocityContext();
		pageQuery.setQuery(query);
		velocityContext.put("log", query);
		velocityContext.put("pageInfos", SystemTools.convertPaginatedList(logService.queryPageList(pageQuery)));
		String viewName = "lims/back/log-list.vm";
		ViewVelocity.view(request, response, viewName, velocityContext);
	}

}
